// UartDBGDlg.h : header file
//

#if !defined(AFX_UARTDBGDLG_H__088F5D18_2DC3_4F3C_A089_CEFCDAD3AA2D__INCLUDED_)
#define AFX_UARTDBGDLG_H__088F5D18_2DC3_4F3C_A089_CEFCDAD3AA2D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "HexEdit.h"
/////////////////////////////////////////////////////////////////////////////
// CUartDBGDlg dialog

class CUartDBGDlg : public CDialog
{
// Construction
public:
	~CUartDBGDlg();
	static const UINT mg_nDefaultComMsg;
	CUartDBGDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	//{{AFX_DATA(CUartDBGDlg)
	enum { IDD = IDD_UARTDBG_DIALOG };
	CHexEdit	m_SndEdit;
	CHexEdit	m_RcvEdit;
	CButton	m_btOpenClose;
	CComboBox	m_cbStop;
	CComboBox	m_cbParity;
	CComboBox	m_cbFlow;
	CComboBox	m_cbBaud;
	CComboBox	m_cbData;
	CComboBox	m_cbPort;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CUartDBGDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CUartDBGDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnOpenclose();
	afx_msg void OnSetChange();
	afx_msg void OnButtonSnd();
	afx_msg void OnButtonTest();
	//}}AFX_MSG
	afx_msg LRESULT OnSerialMsg (WPARAM wParam, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
private:
	int WaitEvent(LPDWORD lpEvtMask);
	void OnEvent(WPARAM wParam, LPARAM lParam);
	int UartRead(void *pData, size_t iLen);
	int UartWrite(void* pData, size_t iLen, DWORD* pdwWritten);
	void StopListen();
	int StartListen(CString &s);
	int GetCB(CComboBox *pBox, CString &c);
	LPSTR GetHandshaking(DCB * d);
	void SetCB(CComboBox *pBox, CString &c);
	void GetUartConf(void);
	void OpenCloseTog(void);
	void ShowLastError(void);
	int GetUartList(void);
	CStatusBarCtrl * m_StatBar;
	HANDLE m_hUart;
	HANDLE m_hevtStop, m_hevtCommEvent, m_hevtRcvEvent;
	HANDLE m_hThread;	
protected:
	DWORD ThreadProc(void);
	static DWORD WINAPI ThreadProc(LPVOID lpArg);

};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_UARTDBGDLG_H__088F5D18_2DC3_4F3C_A089_CEFCDAD3AA2D__INCLUDED_)
